// 答案
const mongoose = require('mongoose')

const {Schema, model} = mongoose

const CommentSchema =  {
  __v:{type: Number,select:false},
  commentor: {type: Schema.Types.ObjectId, ref: 'User', required: true}, // 评论人
  content: {type: String, required: true}, // 评论内容
  questionId: {type: String, required: true}, // 评论从属的问题
  answerId: {type: String, required: true}, // 评论从属的回答
  rootComment: {type: String}, // 根评论,分为一二级评论
  replyTo:{type: Schema.Types.ObjectId, ref: 'User'}, // 回复对象
  childrenReply: {type: [{type: Schema.Types.ObjectId, ref: 'Comment'}]}
}

module.exports = model('Comment', CommentSchema)